package com.itshizhan.designpattern.builder;

public class AppMain  {
    public static void main(String[] args) {
        if(args.length!=1){
            usage();
            System.exit(0);
        }
        if (args[0].equals("plain")){
            TextBuilder textBuilder = new TextBuilder();
            Director director = new Director(textBuilder);
            director.construct();
            String result = textBuilder.getRestult();
            System.out.println(result);
        }else if(args[0].equals("html")){
            HtmlBuilder htmlBuilder = new HtmlBuilder();
            Director director = new Director(htmlBuilder);
            director.construct();
            String result = htmlBuilder.getRestult();
            System.out.println(result + "文件编写完成");
        }else{
            usage();
            System.exit(0);
        }
    }

    public static void usage(){
        System.out.println("Usage: java main plain 编写纯文本文档");
        System.out.println("Usage: java main HTML  编写HTML文档");
    }
}
